import java.util.BitSet;


public class DirectionBitSet 
{
	
	BitSet bitSet = new BitSet();
	int counter;
	
	public DirectionBitSet()
	{
		bitSet = new BitSet();
		counter = 0;
	}
	
	public void append( Move.Direction direction )
	{
		boolean[] bits = direction.getBits();
		
		bitSet.set( counter, bits[1] );
		bitSet.set( counter+1, bits[0] );
		
		counter += 2;
	}
	
	@Override
	public String toString()
	{

//		String[] directions = new String[ bitSet.length()/2 ];
		
		int length =  bitSet.length();
		
		StringBuilder sb = new StringBuilder();
		
//		for ( int i = 0; i < directions.length; i++)
		for ( int i = 0; i < length; i+=2)
		{
			  int number = 0;
			  
			  if ( bitSet.get( i ) )
			  {
				  number += 1;
			  }
			  if ( bitSet.get( i+1 ) )
			  {
				  number += 2;
			  }
			
//			directions[i] = Move.Direction.create( number );
			sb.append( Move.Direction.create( number ) );
		}
		
//		return directions;
		return sb.toString();
	}

}
